package com.yuwubao.hz_International.util

import net.glxn.qrgen.core.image.ImageType
import net.glxn.qrgen.javase.QRCode
import java.io.File
import java.io.FileOutputStream
import java.util.*


fun genQrCode(content: String): String {
    val code = QRCode.from(content)
    code.withSize(430, 430)
    code.withCharset("utf-8")
    val uuid = UUID.randomUUID().toString().replace("-", "")
    val out = code.to(ImageType.PNG).stream()
    val filename = "$uuid.png"
    val file = File("/tmp/img/$filename")
    val outStream = FileOutputStream(file)
    outStream.write(out.toByteArray())
    outStream.flush()
    outStream.close()
    out.close()
    return "http://47.104.170.54/img/$filename"
}